# 15.py
# 实例属性 三个

l = [1, 2, 3, 4, 5]
print(l[3])

print(l[1:4:2])

print(100*'=')

class Person:
  def __init__(self):
    self.items = [1, 2, 3, 4, 5, 6, 7, 8]

  def __getitem__(self, key):
    return self.items[key]
  
  def __setitem__(self, key, value):
    if isinstance(key, slice):
      self.items[key] = value
  
    # print(key.start)
    # print(key.stop)
    # print(key.step)
  def __delitem__(self, key):
    del self.items[key]

p = Person()
p[0:4:2] = ['a', 'b']
print(p.items)

# p['name'] =  'sz'

print(p[3])
del p[0:2:1]
print(p.items)
